//
//  YLHomeStatusViewModel.swift
//  weiBo
//
//  Created by 杨雷 on 2016/12/6.
//  Copyright © 2016年 Yang.L. All rights reserved.
//

import UIKit

class YLHomeStatusViewModel: NSObject {
    //数据模型
    lazy var statusList: [YLStatusViewModel] = [YLStatusViewModel]()
    
    
    func loadData (callBack: @escaping (Bool)->()) {
        YLNetworkTools.sharedTools.requestStatus { (response, error) in
            if error != nil {
                print(error!)
                return
            }
            //请求成功
            let dic = response as! [String: Any]
            let statusDicArray = dic["statuses"] as! [[String: Any]]
            
           
            let modelArray = NSArray.yy_modelArray(with: YLStatus.self, json: statusDicArray) as! [YLStatus]
            
            var tempArray = [YLStatusViewModel]()
            for model in modelArray {
                let viewModel = YLStatusViewModel()
                viewModel.status = model
                tempArray.append(viewModel)
            }
            
            self.statusList = tempArray
    
            callBack(true)
            
        }
    }

    
    
    
    
}
